@extends("layouts.backend.webadmin")
@section('page-header')
    <h1>
        <small>knowledge</small>
    </h1>
@endsection

@section('content')
    <link rel="stylesheet" href="{{env('APP_ROOT')}}/assets/select2/css/select2.min.css">
    <!-- Main content -->
    <section class="content">
        <div class="row">
            <div class="col-xs-12">

                <div class="box">

                    <div class="box-body">
                        @if($errors->any())
                            <ul class="alert alert-danger">
                                @foreach($errors->all() as $error)
                                    <li>{{ $error }}</li>
                                @endforeach
                            </ul>
                        @endif
                        <form method="post" action="{{ URL::route('knowledge.store') }}">
                            <div class="form-group">
                                <label for="name">标题</label>
                                <input value="{{old('title')}}" name="title" type="text" class="form-control" placeholder="标题">
                            </div>
                            <div class="form-group">
                                <label for="category_id">关联漏洞类型</label>
                                <select class="form-control select2" multiple aria-hidden="true" name="category_id[]">
                                    <option value="0">--文章分类--</option>
                                    @foreach($categories as $category)
                                        <option @if(old('category_id')==$category->id) selected @endif value="{{$category->id}}">{{$category->name}}</option>
                                    @endforeach
                                </select>
                            </div>
                            {{--富文本--}}
                            <div class="form-group">
                                <label>内容</label>
                                <!-- 加载编辑器的容器 -->
                                <script id="container" name="content" type="text/plain"></script>
                            </div>
                            {!! csrf_field() !!}
                            <button type="submit" class="btn btn-primary">提交</button>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </section>
@stop
@section('javascript-end')
    <script src="{{env('APP_ROOT')}}/assets/select2/js/select2.min.js"></script>
    @include('UEditor::head');
    <script>
        $(function () {
            $('.select2').select2({"border-radius":'0px'});
        });
        var toolbars = [[
            'fullscreen', 'source', '|', 'undo', 'redo', '|', 'blockquote', 'forecolor', 'backcolor', 'removeformat', '|',
            'imagenone', 'imageleft',
            'imageright', 'imagecenter', '|', 'link', 'unlink', 'anchor', 'simpleupload', 'insertimage', '|',
        ], [
            'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|','insertcode',
        ]];
        //实例化编辑器
        var ue = UE.getEditor('container', {
            toolbars: toolbars,
            initialFrameHeight: 350,
            serverUrl: "{{env('APP_ROOT')}}"+window.UEDITOR_CONFIG.serverUrl
        });
    </script>
@endsection